package com.example.leetcode.niuke;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s1 = scanner.nextLine();
        String s2 = scanner.nextLine();
        String[] split1 = s1.split("\\.");
        String[] split2 = s2.split("\\.");
        int i = 0;
        String r =null;
        int max = Math.min(split1.length,split2.length);
        while (i <= max -1) {
            if (i != max -1) {
                Integer fill = fill(split1[i]);
                Integer fill1 = fill(split2[i]);
                if (!Objects.equals(fill,fill1)) {
                    r = fill > fill1 ? s1 : s2;
                    break;
                }
            }else {
                String[] split = split1[i].split("-");
                String[] split3 = split2[i].split("-");
                if (fill(split[0]) > fill(split3[0])) {
                    r =s1;
                    break;
                }else if (fill(split[0]) < fill(split3[0])) {
                    r = s2;
                    break;
                } else if(split.length ==1 ){
                    r =s1;
                } else {
                    String[] ss = {split[1],split3[1]};
                    Arrays.sort(ss);
                    if (Objects.equals(ss[0],split[1])) {
                        r = s2;
                    }else {
                        r = s1;
                    }
                }
            }
            i++;
        }
        if (r == null) {
            r = split1.length > split2.length ? s1 : s2;
        }
        System.out.println(r);
    }

    private static  boolean isNumber(String s) {
        try {
            int i = Integer.parseInt(s);
            return true;
        }catch (Exception e) {
            return false;
        }
    }



    private static Integer fill(String s1) {
        if (s1.equals("\"\"")) {
            return -1;
        }
        StringBuilder stringBuilder = new StringBuilder();
        boolean add = s1.charAt(0) != '0';
        if (add) {
            return Integer.parseInt(s1);
        }else {
            for (int j =0;j<s1.length();j++) {
                if (s1.charAt(j) != '0') {
                    add = true;
                }
                if (add) {
                    stringBuilder.append(s1.charAt(j));
                }
            }
            return isNumber(stringBuilder.toString()) ? Integer.parseInt(stringBuilder.toString()) : -1;
        }
    }
}
